import os 

import json
import subprocess
directory={}
for i in range(70,90):
    step=i/10
    
    process1=subprocess.Popen(['openMVG_main_ComputeMatches','-i','/home/david/develop/3dRe/output/project_ANNL2/matches/sfm_data.json','-o','/home/david/develop/3dRe/output/project_ANNL2/matches','-g','a','-n','ANNL2','-r',str(step),'-f','1'], stdout=subprocess.PIPE, universal_newlines=True)
    process1.wait()
    process2=subprocess.Popen(['openMVG_main_IncrementalSfM','-i','/home/david/develop/3dRe/output/project_ANNL2/matches/sfm_data.json','-m','/home/david/develop/3dRe/output/project_ANNL2/matches','-o','/home/david/develop/3dRe/output/project_ANNL2/reconstruction'],stdout=subprocess.PIPE, universal_newlines=True)
    process2.wait()
    # print(process.stdout)
     
    stri=""
    for stdout_line in iter(process2.stdout.readline, ""):
        stri+=stdout_line
    index=stri.find('-- #Tracks, #3D points: ')
    print("stri:",stri)
    
    result=stri[index+24:index+28]
    directory[step]=result
    break
with open("result.json", "w") as outfile:
    json.dump(directory,outfile)